<?php

Raise::load('control.RaiseTimeAgo');
Raise::load('control.RaiseRepeater');

class IndexPage extends AppPage {
    
    function __construct($p){
        parent::__construct($p, 'IndexPage');
    }
    
    protected function prepare($app) {
        $this->title('phpRaise PHP Framework');
        $this->assets()->add('defaultCss', 'static/styles/default.css');
        $this->assets()->add('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
    }

    function build(){
        
        $repeater = new RaiseRepeater(new RaiseTemplate('<div class="content-page" id="{id}">
                    <h1>{title}</h1>
                    {content}
                </div>'));
        //$repeater->data()->columns()->add('id');
        //$repeater->data()->columns()->add('title');
        //$repeater->data()->columns()->add('content');
        
        $message = 'phpRaise {framework.version} is <b>now up and running healthily</b>. You can start developing your PHP application by following the <a href="http://mauris.sg/phpraise/start/developing">Getting Started guide</a> and have it up in no time.';
        if(error_get_last() !== null){
            $message = 'Oops! There seems to be some problem. phpRaise {framework.version} showed some errors at the top. Please fix them before continuing. If you have any problems please submit a ticket.';
        }
        
        $repeater->data()->add(array(
            'id' => 'welcome',
            'title' => 'Congratulations',
            'content' => RaiseHtml::listWrap(array(
                    $message,
                    'The object oriented PHP framework developed for human developers and the Web. You can be assured that phpRaise was designed with you in mind, allowing you to focus on your application and business logic. Take a look at <a href="#features" class="internal">what’s in store for you</a> and you’ll be amazed.',
                    'Take a look at our <a href="#demo" class="internal">demonstrations</a> to see how powerful phpRaise really is and what features are available at your disposal.',
                ), '<p>', '</p>')
        ));
        
        $repeater->data()->add(array(
            'id' => 'features',
            'title' => 'Features',
            'content' => '<ul>'. RaiseHtml::listWrap(array(
                    'Model-View-Controller (MVC) architecture design',
                    'Flexible, Extensible, High Compatibility',
                    'Concrete and Pure Object Oriented Development Environment',
                    'RESTful Routing and clean parameterized URLs',
                    'Access Control and User Authentication',
                    'Strict security processing for input and output',
                    'Easy to use user-interface building classes',
                    'Helper classes such as RaiseCollection, RaiseString, RaiseFile and RaiseRegex readily available for use',
                )) . '</ul>'
        ));
        
        $repeater->data()->add(array(
            'id' => 'whatsnew',
            'title' => 'What\'s New?',
            'content' => '<ul>'. RaiseHtml::listWrap(array(
                    'Internationalization and localization support with message translation',
                    'Caching support by Memcache',
                    'Asset management on pages',
                    'RESTful URL Routing',
                    'Local / Server separate configuration',
                    'Refactoring of Application Actions',
                    'Major bug fixing and performance improvement',
                )) . '</ul>'
        ));
        $repeater->data()->add(array(
            'id' => 'demo',
            'title' => 'Demo',
            'content' => RaiseHtml::listWrap(array(
                    'Now that you have installed phpRaise, you must be wondering what are the real gimmicks of the framework. Browse through the Demo of phpRaise showcasing almost all aspects of the framework.', 
                    'Fascinating features and demostrations of phpRaise can be <a href="http://mauris.sg/phpraise/demo" target="_blank">found here</a>.',
                ), '<p>', '</p>')
        ));
        $repeater->data()->add(array(
            'id' => 'recipes',
            'title' => 'Recipes',
            'content' => RaiseHtml::listWrap(array(
                'Cooking a great dish is not difficult when one follow a great recipe. Recipes will help provide you with step by step guide tailored to solve certain problems and difficulties you may encounter when developing in phpRaise.',
                'Our amazing collection of recipes for developing great phpRaise applications can be <a href="http://mauris.sg/phpraise/recipes" target="_blank">found here</a>.'
                ), '<p>','</p>')
        ));
        
        $this->define('contentPages', $repeater);
        $this->define('framework.version', Raise::version()->__toString());
    }

}